<script src="/javascripts/validation/jquery.validate.js" type="text/javascript"></script>
<script src="/javascripts/validation/validate_order.js" type="text/javascript"></script>
<div class='form'>
  <% form_for @order do |f| %>
    <%= f.error_messages %>
    <label for="order_paytype">送货地址</label>[<a href="/users/<%=session[:user_id]%>/addresses">管理</a>]
    <div class="address">
      <% if @order_owen.addresses.size > 0 %>
        <% @order_owen.addresses.each do |a| %>
          <%=radio_button("order", "address_id",a.id,{:onclick=>"changeHiddenValue(this.value);"})%><%=a.title%><span></span> <br />
        <% end %>

        <p>
          <label for="order_shipping_tpe">送货方式</label>
          <%=select("order", "shipping_type",Order::SHIPPING_TYPE,:prompt => "请选择..")%>
          <span></span>
          <span id="logistic_fee" ></span>
        </p>

        <p>
          <label for="order_paytype">支付方式</label>
          <%=select("order", "paytype",Order::PAYTYPE,:prompt => "请选择..")%>
          <span></span>
        </p>
        <p>
          <label for="order_remark">附言</label>
          <%= f.text_area :remark,:rows=>'2' %>
        </p>

        <p>
          <label for="order_point">使用积分</label>
          <%= f.text_field :used_point,:size=>'5' %>
          账号可用积分<span style="color:maroon;"><%=@user.point%></span>，100积分抵现金1元。(<a href="/store/fqa#point">如何获得积分?</a>)
        </p>

        <% if admin? && @order.id %>
          <p>
            <label for="order_status">订单状态</label>
            <%= format_status(order.status) %>
          </p>
          <p>
            <label for="order_shipping_remark">物流单号</label>
            <%= f.text_field :shipping_remark,:size=>'10' %>
          </p>

          <p>
            <label for="order_pay_remark">付款备注</label>
            <%= f.text_area :pay_remark,:rows=>'2' %>
          </p>
        <%end%>

        <p>
          <%=image_submit_tag '/images/register.jpg',:style=>"border:none;margin-left:1em;" %>
        </p>


      <%else%>
        第一次惠顾? 请先<a href="/users/<%=session[:user_id]%>/addresses/new" >添加送货地址</a>
      <%end%>
    </div>
  <% end %>
</div>
<input type="hidden"  id="hidden_address_id" />
